﻿using System;
using System.ComponentModel;
using RrslLite.Net.Messages;

namespace RrslLite.Net.Contracts
{
    public class InvokeOperationsAsyncCompletedArgs<TResult> : AsyncCompletedEventArgs
	{
		protected object[] Results;

		public InvokeOperationsAsyncCompletedArgs(object[] results, Exception exception, bool cancelled, object userState) :
			base(exception, cancelled, userState)
		{
			this.Results = results;
		}

		public TResult Result
		{
			get
			{
				RaiseExceptionIfNecessary();
				return (TResult)Results[0];
			}
		}
	}

	public class InvokeOperationsAsyncCompletedArgs : InvokeOperationsAsyncCompletedArgs<Message[]>
	{
		public InvokeOperationsAsyncCompletedArgs(object[] results, Exception exception, bool cancelled, object userState) :
			base(results, exception, cancelled, userState)
		{
			this.Results = results;
		}
	}
}
